package com.hundsun.cprs.yyt.service.goods.enums;

import java.util.HashMap;
import java.util.Map;

public enum EnumGoodsStatus {
    PUBLISHED("1","已上架"),
    CANCEL_PUBLISH("2","已下架");

    /** 状态值 */
    private String code;
    /** 状态值说明 */
    private String desc;

    private EnumGoodsStatus(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 全局索引池
     */
    private static Map<String, EnumGoodsStatus> pool = new HashMap<String, EnumGoodsStatus>();
    static {
        for (EnumGoodsStatus et : EnumGoodsStatus.values()) {
            pool.put(et.code + "", et);
        }
    }

    /**
     * 根据内容索引
     *
     * @param code
     * @return
     */
    public static EnumGoodsStatus indexByValue(String code) {
        return pool.get(code);
    }

    public static Map<String, EnumGoodsStatus> toMap() {
        return pool;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
}
